#include  <cstdio>

bool prime[100001];	//	0表示是质数
int res[100001];

void init()
{
	prime[1] = 1;
	for( int i = 2 ; i < 100000 ; ++i )
	{
		if(prime[i] != 1)
			for( int j = 2; j*i < 100000 ; ++j )
				prime[j*i] = 1;			
	}
	
	int last_prime = 2;
	int sum = 0;
	res[1] = 0;
	res[2] = 0;

	for( int i = 3 ; i < 100000 ; ++i )
	{
		if( prime[i] == 0 )
		{
			if( i - last_prime == 2 )
			{
				sum++;
				res[i] = sum;
				last_prime = i;
			}
			else
			{
				res[i] = sum;
				last_prime = i;
			}
		} 
		else
			res[i] = sum;
	}
	
}

int main(int argc, char *argv[])
{
	init();
	int n;
	scanf("%d",&n);
	while( n > 0 )
	{
		printf("%d\n",res[n]);
		scanf("%d",&n);
	}
}
